<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		//设置编码格式
		request.setCharacterEncoding("utf-8");
		//获取表单信息
		String uname = request.getParameter("un");  //用户名
		String upwd = request.getParameter("pwd");  //密码
		int time = Integer.parseInt(request.getParameter("t"));  //时间
		
		if(uname.equals("admin") && upwd.equals("123456")){
			//将用户信息保存到session中
			session.setAttribute("uname", uname);
			//设置session有效时间
			session.setMaxInactiveInterval(time);
			//chogndingxiang
			response.sendRedirect("Demo5.jsp");
		}else{
			out.print("用户名密码错误，请出从新登录！3秒后自动进入登录页面");
			//销毁session对象
			session.invalidate();
			//设置页面自动跳转
			response.setHeader("refresh", "3;url=Demo3.jsp");
		}
	%>
</body>
</html>